package co.baiku.boot.im.tencent.request.data;

import co.baiku.boot.common.tools.RandomTools;
import co.baiku.boot.im.tencent.model.TencentImMsgPriority;
import co.baiku.boot.im.tencent.model.TencentImOfflinePushInfo;
import co.baiku.boot.im.tencent.model.TencentMsgBody;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 发送群消息
 */
public class SendGroupMsgData implements TencentImRequestData{
    /**
     * 群组ID（必填）
     */
    @JsonProperty("GroupId")
    private String groupId;
    /**
     * 随机数字，五分钟数字相同认为是重复消息（必填）
     */
    @JsonProperty("Random")
    private Integer random;
    /**
     * 消息体，由一个element数组组成，详见字段说明（必填）,详细可参阅 <a href='https://cloud.tencent.com/document/product/269/2720'>消息格式描述</a>
     */
    @JsonProperty("MsgBody")
    private List<TencentMsgBody> msgBody = new ArrayList<>();

    /**
     * 指定消息发送者（选填）
     */
    @JsonProperty("From_Account")
    private String fromAccount;
    /**
     * 表示只在线下发(只有在线群成员才能收到)，不存离线及漫游
     * <p>
     * 如果消息体中指定 OnlineOnlyFlag，只要值大于0，则消息表示只在线下发，不存离线和漫游（AVChatRoom 和 BChatRoom 不允许使用）。
     * </p>
     * 1表示消息仅发送在线成员，默认0表示发送所有成员，音视频聊天室（AVChatRoom）和在线成员广播大群（BChatRoom）不支持该参数
     */
    @JsonProperty("OnlineOnlyFlag")
    private Integer onlineOnlyFlag;
    /**
     * 消息优先级（选填）
     * <p>
     * 可以指定消息的优先级，默认优先级 Normal。<br/>
     * 可以指定4种优先级，从高到低依次为 High、Normal、Low 以及 Lowest，区分大小写。
     * </p>
     */
    @JsonProperty("MsgPriority")
    private TencentImMsgPriority msgPriority = TencentImMsgPriority.Normal;
    /**
     * 消息回调禁止开关，只对单条消息有效，
     * eg:
     * <p>
     * ForbidBeforeSendMsgCallback 表示禁止发消息前回调，
     * ForbidAfterSendMsgCallback 表示禁止发消息后回调
     * </p>
     */
    @JsonProperty("ForbidCallbackControl")
    private List<String> forbidCallbackControl;
    /**
     * 离线推送信息配置，详细可参阅 <a href='https://cloud.tencent.com/document/product/269/2720'>消息格式描述</a>
     */
    @JsonProperty("OfflinePushInfo")
    private TencentImOfflinePushInfo offlinePushInfo;

    public SendGroupMsgData() {
        this.random = RandomTools.number(1000000, 9999999);
    }

    public SendGroupMsgData(String groupId, List<TencentMsgBody> msgBody) {
        this(groupId, msgBody, null);
    }

    public SendGroupMsgData(String groupId, TencentMsgBody... msgBody) {
        this(groupId, Arrays.asList(msgBody), null);
    }

    public SendGroupMsgData(String groupId, List<TencentMsgBody> msgBody, TencentImOfflinePushInfo offlinePushInfo) {
        this();
        this.groupId = groupId;
        this.msgBody = msgBody;
        this.offlinePushInfo = offlinePushInfo;
    }

    public Integer getOnlineOnlyFlag() {
        return onlineOnlyFlag;
    }

    public void setOnlineOnlyFlag(Integer onlineOnlyFlag) {
        this.onlineOnlyFlag = onlineOnlyFlag;
    }

    public List<String> getForbidCallbackControl() {
        return forbidCallbackControl;
    }

    public void setForbidCallbackControl(List<String> forbidCallbackControl) {
        this.forbidCallbackControl = forbidCallbackControl;
    }

    public TencentImMsgPriority getMsgPriority() {
        return msgPriority;
    }

    public void setMsgPriority(TencentImMsgPriority msgPriority) {
        this.msgPriority = msgPriority;
    }

    public String getFromAccount() {
        return fromAccount;
    }

    public void setFromAccount(String fromAccount) {
        this.fromAccount = fromAccount;
    }

    public TencentImOfflinePushInfo getOfflinePushInfo() {
        return offlinePushInfo;
    }

    public void setOfflinePushInfo(TencentImOfflinePushInfo offlinePushInfo) {
        this.offlinePushInfo = offlinePushInfo;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public Integer getRandom() {
        return random;
    }

    public void setRandom(Integer random) {
        this.random = random;
    }

    public List<TencentMsgBody> getMsgBody() {
        return msgBody;
    }

    public void setMsgBody(List<TencentMsgBody> msgBody) {
        this.msgBody = msgBody;
    }
}
